package com.itheima.test_dome.controller;

import com.itheima.test_dome.pojo.User;
import com.itheima.test_dome.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据id查询用户
     * @param id
     */
    @GetMapping
    public void getById(Integer id){
        userService.getById(id);
    }

    /**
     * 根据id删除用户
     * @param id
     */
    @DeleteMapping
    public void deleteById(Integer id){
        userService.deleteById(id);
    }

    /**
     * 根据id修改用户
     * @param user
     */
    @PostMapping
    public void updataById(User user){
        userService.updataById(user);
    }


    /**
     * 添加用户
     * @param user
     */
    @PutMapping
    public void add(User user){
        userService.add(user);
    }
}
